/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmVectores.java
 *
 * Created on 03-12-2014, 10:33:20 AM
 */
package ejerciciodeconjuntos;

/**
 *
 * @author Estudiante
 */
import Negocio.Conjuntos;
import Negocio.Entero;
import javax.swing.JOptionPane;
import javax.swing.JTable;

public class frmVectores extends javax.swing.JFrame {

    /** Creates new form frmVectores */
    public frmVectores() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnGroup = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabla1 = new javax.swing.JTable();
        btnDim = new javax.swing.JButton();
        txtn = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabla2 = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        tabla0 = new javax.swing.JTable();
        txtn1 = new javax.swing.JTextField();
        btnDim1 = new javax.swing.JButton();
        btnDim2 = new javax.swing.JButton();
        rbUnion = new javax.swing.JRadioButton();
        rbInter = new javax.swing.JRadioButton();
        rbDif = new javax.swing.JRadioButton();
        rbDifSim = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        tabla1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(tabla1);

        btnDim.setText("Dimencionar");
        btnDim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDimActionPerformed(evt);
            }
        });

        tabla2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane2.setViewportView(tabla2);

        tabla0.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane3.setViewportView(tabla0);

        btnDim1.setText("Dimencionar");
        btnDim1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDim1ActionPerformed(evt);
            }
        });

        btnDim2.setText("Calcular");
        btnDim2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDim2ActionPerformed(evt);
            }
        });

        btnGroup.add(rbUnion);
        rbUnion.setText("Union");

        btnGroup.add(rbInter);
        rbInter.setText("Intersepcion");

        btnGroup.add(rbDif);
        rbDif.setText("Diferencia");

        btnGroup.add(rbDifSim);
        rbDifSim.setText("Diferencia Simetrica");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Ejercicio de Conjuntos");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(txtn1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnDim1))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 524, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(txtn, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnDim))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 524, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(229, 229, 229)
                        .addComponent(btnDim2)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(119, 119, 119)
                .addComponent(rbUnion)
                .addGap(18, 18, 18)
                .addComponent(rbInter)
                .addGap(18, 18, 18)
                .addComponent(rbDif)
                .addGap(18, 18, 18)
                .addComponent(rbDifSim)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(464, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 576, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDim))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtn1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDim1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rbUnion)
                    .addComponent(rbInter)
                    .addComponent(rbDif)
                    .addComponent(rbDifSim))
                .addGap(15, 15, 15)
                .addComponent(btnDim2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnDimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDimActionPerformed
        int dim = Integer.parseInt(txtn.getText());
        Object[][] aux = new Object[1][dim];
        String[] titles = new String[dim];
        tabla0.setModel(new javax.swing.table.DefaultTableModel(aux,titles));
    }//GEN-LAST:event_btnDimActionPerformed

    private void btnDim1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDim1ActionPerformed
        int dim = Integer.parseInt(txtn1.getText());
        Object[][] aux = new Object[1][dim];
        String[] titles = new String[dim];
        tabla1.setModel(new javax.swing.table.DefaultTableModel(aux,titles));
    }//GEN-LAST:event_btnDim1ActionPerformed

    private void btnDim2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDim2ActionPerformed
        if(rbUnion.isSelected()){
            Conjuntos A = new Conjuntos(),B = new Conjuntos(),C= new Conjuntos();//Cracion de los tres conjuntos
            A.setDim(Integer.parseInt(txtn.getText()));
            A.vector=cargar(tabla0,A.getDim());
            
            B.setDim(Integer.parseInt(txtn1.getText()));
            B.vector=cargar(tabla1,B.getDim());
            
            JOptionPane.showConfirmDialog(null, B.vector[2].getNum());
        }
        else if(rbInter.isSelected()){
            
        }
        else if(rbDif.isSelected()){
            
        }
        else if(rbDifSim.isSelected()){
            
        }
    }//GEN-LAST:event_btnDim2ActionPerformed
    public Entero[] cargar(JTable tb,int d){
        Entero[] aux= new Entero[d];
        for(int i=0;i<tb.getColumnCount();i++){
            //aux[i].setNum(Integer.parseInt(tb.getValueAt(0, i).toString()));
            //aux[i].setNum(Integer.parseInt(JOptionPane.showInputDialog("1").toString()));
        }
        return aux;
    }
    public void mostrar(){
        
    }
    /**
        tabla = new javax.swing.JTable();

        tabla.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tabla);
     */
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frmVectores().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDim;
    private javax.swing.JButton btnDim1;
    private javax.swing.JButton btnDim2;
    private javax.swing.ButtonGroup btnGroup;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JRadioButton rbDif;
    private javax.swing.JRadioButton rbDifSim;
    private javax.swing.JRadioButton rbInter;
    private javax.swing.JRadioButton rbUnion;
    private javax.swing.JTable tabla0;
    private javax.swing.JTable tabla1;
    private javax.swing.JTable tabla2;
    private javax.swing.JTextField txtn;
    private javax.swing.JTextField txtn1;
    // End of variables declaration//GEN-END:variables
}
